jQuery.ffui = { // 生日选择select options=select标签id setting=设置选定日期
	birthday : function(options, setting) {
		var o = {
			yid : "yid",
			mid : "mid",
			did : "did",
			isTip : true,
			change : function() {
			}
		};

		$.extend(o, options);
		var date = new Date();

		var $selYear = $("#" + o.yid);
		var $selMonth = $("#" + o.mid);
		var $selDay = $("#" + o.did)

		var y = 0, m = 0, d = 0;

		var createYear = function() {
			var html = "";
			if (o.isTip) {
				html += "<option value=''>请选择</option>";
			}

			for (var i = date.getFullYear(); i >= 1900; i--) {
				html += "<option value='" + i + "'>" + i + "年</option>";
			}
			$selYear.html(html);

		};

		var createMonth = function() {
			var html = "";
			if (o.isTip) {
				html += "<option value=''>请选择</option>";
			}
			for (var i = 1; i <= 12; i++) {
				html += "<option value='" + i + "'>" + i + "月</option>";
			}
			$selMonth.html(html);

		};

		var createDay = function(y, m) {
			if (y != "" && m != "" && y != 0 && m != 0) {
				var days = 0;
				if (m == 1 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12) {
					days = 31;
				} else if (m != 2) {
					days = 30;
				} else {
					if ((y % 4 == 0 && y % 100 != 0) || y % 400 == 0) {
						days = 29;
					} else {
						days = 28;
					}
				}

				var html = "";
				if (o.isTip) {
					html += "<option value=''>请选择</option>";
				}
				for (var i = 1; i <= days; i++) {
					html += "<option value='" + i + "'>" + i + "日</option>";
				}

				$selDay.html(html);

			}
		};

		var isSameType = function(m1, m2) {
			var monthType = {
				1 : [1, 5, 7, 8, 10, 12],
				2 : [2],
				3 : [3, 4, 6, 9, 11]
			};
			var m1Type = -1;
			var m2Type = -1;
			$.each(monthType, function(key, val) {
						$(val).each(function(i, d) {
									if (m1 == d) {
										m1Type = key;
									}
									if (m2 == d) {
										m2Type = key;
									}
								});

					});

			return m1Type == m2Type;
		};

		$selYear.change(function() {
					if ($selMonth.val() == "2") {
						createDay($selYear.val(), $selMonth.val());
					}

					o.change($selYear.val(), $selMonth.val(), $selDay.val());
					y = parseInt($selYear.val());
				});
		$selMonth.change(function() {
					if (!isSameType(m, parseInt($selMonth.val()))) {
						createDay($selYear.val(), $selMonth.val());
						o
								.change($selYear.val(), $selMonth.val(),
										$selDay.val());
						m = parseInt($selMonth.val());
					}
				});
		$selDay.change(function() {
					o.change($selYear.val(), $selMonth.val(), $selDay.val());
				});

		createYear();
		createMonth();
		createDay(y, m);

		// 设置日期

		var s = {
			y : "",
			m : "",
			d : ""
		};
		$.extend(s, setting);

		setTimeout(function() {
					$selYear.val(s.y);
				}, 20);
		setTimeout(function() {
					$selMonth.val(s.m).change();
				}, 20);

		setTimeout(function() {
					$selDay.val(s.d);
				}, 300);

	}
};